package com.ruoyi.edit.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.edit.domain.CourseTimeContent;
import com.ruoyi.edit.service.ICourseTimeContentService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课程时间段内容Controller
 * 
 * @author qiufeng
 * @date 2022-03-29
 */
@Controller
@RequestMapping("/system/timeContent")
public class CourseTimeContentController extends BaseController
{
    private String prefix = "system/timeContent";

    @Autowired
    private ICourseTimeContentService courseTimeContentService;

    @GetMapping()
    public String timeContent()
    {
        return prefix + "/timeContent";
    }


    @GetMapping("/timeContentList")
    public String timeContentList(String id, ModelMap mmap)
    {
        mmap.put("vendorPackageId", id);
        return prefix + "/timeContent";
    }

    /**
     * 查询课程时间段内容列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CourseTimeContent courseTimeContent)
    {
        startPage();
        List<CourseTimeContent> list = courseTimeContentService.selectCourseTimeContentList(courseTimeContent);
        return getDataTable(list);
    }

    /**
     * 导出课程时间段内容列表
     */
    @Log(title = "课程时间段内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CourseTimeContent courseTimeContent)
    {
        List<CourseTimeContent> list = courseTimeContentService.selectCourseTimeContentList(courseTimeContent);
        ExcelUtil<CourseTimeContent> util = new ExcelUtil<CourseTimeContent>(CourseTimeContent.class);
        return util.exportExcel(list, "课程时间段内容数据");
    }

    /**
     * 新增课程时间段内容
     */
    @GetMapping("/add")
    public String add(String vendorPackageId, ModelMap mmap)
    {
        mmap.put("vendorPackageId", vendorPackageId);
        return prefix + "/add";
    }

    /**
     * 新增保存课程时间段内容
     */
    @Log(title = "课程时间段内容", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CourseTimeContent courseTimeContent)
    {
        return toAjax(courseTimeContentService.insertCourseTimeContent(courseTimeContent));
    }

    /**
     * 修改课程时间段内容
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        CourseTimeContent courseTimeContent = courseTimeContentService.selectCourseTimeContentById(id);
        mmap.put("courseTimeContent", courseTimeContent);
        return prefix + "/edit";
    }

    /**
     * 修改保存课程时间段内容
     */
    @Log(title = "课程时间段内容", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CourseTimeContent courseTimeContent)
    {
        return toAjax(courseTimeContentService.updateCourseTimeContent(courseTimeContent));
    }

    /**
     * 删除课程时间段内容
     */
    @Log(title = "课程时间段内容", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(courseTimeContentService.deleteCourseTimeContentByIds(ids));
    }
}
